package com.example.tangjiangxu.kotlintest

import android.app.Activity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_login.*

open class LoginActivity : Activity() {
    val TAG:String = "LoginActivity"
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)

        bn_login.setOnClickListener {
            var user:User = User()
            user.name = et_name.text.toString().trim()
            user.password = et_password.text.toString().trim()
            login(user)
        }
    }

    /**
     * 用户登录
     */
    fun login(user:User) {
        if (login(user.name, user.password)) {
            finish()
            showToast(this, "登录成功")
        } else {
            showToast(this, "登录失败")
        }
    }
}
